package com.linskating.wheat.exception;

import com.linskating.wheat.common.BaseResponse;
import com.linskating.wheat.common.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalException {

    @ExceptionHandler(BusinessException.class)
    public <T> BaseResponse<T> businessExceptionHandle(BusinessException e) {
        log.info("BusinessException: {}", e.getMessage());
        return ResultUtils.error(e.getErrorCode(), e.getDescription());
    }
}
